package com.tencent.wxcloudrun.utils;

import com.tencent.wxcloudrun.model.AdminUser;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * ClassName: Tools
 * Package: com.tencent.wxcloudrun.utils
 * Description:
 *
 * @Date: 2023/1/31 7:39 PM
 * @Author: wht
 */
public class Tools {
    public static String encryptPassword(String password) throws NoSuchAlgorithmException {
        MessageDigest md = MessageDigest.getInstance("SHA-256");
        md.update(password.getBytes());
        byte[] bytes = md.digest();
        StringBuilder sb = new StringBuilder();
        for (byte b : bytes) {
            sb.append(String.format("%02x", b));
        }
        return sb.toString();
    }
    public static String getInitPwd() throws NoSuchAlgorithmException {
        AdminUser user = ThreadLocalTool.getUser();
        String mobile = user.getMobile();

        String password = encryptPassword("123456" + mobile.substring(7));

        return password;
    }
}
